package com.ttbj.error.component;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ttbj.error.dao.ErrorMapper;
import com.ttbj.util.DateUtils;
import com.ttbj.error.po.Error;

@Component
public class ErrorComponent {

	@Autowired
	ErrorMapper errorMapper = null;

	public void insert(Long orderId, String orderNum, String wxPayNum, Integer reason, String errorDesc) {
		String insTime = DateUtils.getCurDttStr();
		Error error = new Error(orderId, reason, insTime, errorDesc, wxPayNum);
		errorMapper.insertSelective(error);
	}

	public void paramReson(Long orderId, String orderNum, String wxPayNum) {
		Integer reason = 1;
		String errorDesc = "参数原因引起的支付异常";
		insert(orderId, orderNum, wxPayNum, reason, errorDesc);

	}

	public void sysReson(Long orderId, String orderNum, String wxPayNum) {
		Integer reason = 2;
		String errorDesc = "系统原因引起的支付异常";
		insert(orderId, orderNum, wxPayNum, reason, errorDesc);
	}
	
	public void codeReson(Long orderId, String orderNum, String wxPayNum) {
		Integer reason = 3;
		String errorDesc = "生成二维码出错引起的支付异常";
		insert(orderId, orderNum, wxPayNum, reason, errorDesc);
	}

	public void waybillReson(Long orderId, String orderNum, String wxPayNum) {
		Integer reason = 4;
		String errorDesc = "车辆派单出错引起的支付异常";
		insert(orderId, orderNum, wxPayNum, reason, errorDesc);
	}
	
}
